#include <iostream>
using namespace std;
struct A{
	int n;
	A(){ cout << "A构造" << endl; }
	A(int n) :n(n){ cout << "A构造" << endl; }
	~A(){ cout << "A析构" << endl; }
};
struct B :public A{
	int n;
	B(){ cout << "B构造" << endl; }
	B(int a, int b) :n(a), A(b){ cout << "B构造" << endl; }
	~B(){ cout << "B析构" << endl; }
};
struct C:public B{
	int n;
	C(){ cout << "C构造" << endl; }
	C(int a, int b, int c) :n(c), B(a, b){ cout << "C构造" << endl; }
	~C(){ cout << "C析构" << endl; }
};
int main(){
	C* p = new C(1,2,3);
	cout << p->n << endl;//3
	cout << p->B::n << endl;//1
	cout << p->B::A::n << endl;//2

int* p1 = (int*)p;
	for (int i = 0; i < 3; i++)
		cout << *p1++ << " "; //2 1 3
	cout << endl;


	delete p;
	

	while (1);
	return 0;
}